package net.starwifi.duobao.web;

import net.starwifi.duobao.entity.Member;
import net.starwifi.duobao.mvc.BaseController;
import net.starwifi.duobao.mvc.Message;
import net.starwifi.duobao.service.MemberService;
import net.starwifi.duobao.service.TransferService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;


@Controller("wapTransferController")
@RequestMapping(value = "/transfer")
public class TransferController extends BaseController {

    @Autowired
    TransferService transferService;

    @Autowired
    MemberService memberService;
    /**
     * 发红包
     */
    @ResponseBody
    @RequestMapping(value = "/create", method = RequestMethod.POST)
    public Object transfer(String mobile,BigDecimal fee) {
        if(mobile==null){
            return Message.error("对方手机号不能为空");
        }
        if(fee==null){
            return Message.error("转账金额不能为空");
        }
        Member currentMem=memberService.getCurrent();
        return transferService.hb(currentMem.getId(),mobile,fee);
    }
}
